﻿#region

using System.ServiceModel;
using Autofac;
using Autofac.Integration.Mvc;
using BTL.OnlineTestingSocial.Application.Web.Infrastructure.ServiceFacades;
using BTL.OnlineTestingSocial.Services.TestingEngine.Contract;

#endregion

namespace BTL.OnlineTestingSocial.Application.Web
{
    public class MainModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder.Register(c => new ChannelFactory<ITestingEngineService>("TestingEngineService")).SingleInstance().
                CacheInSession();
            builder.Register(c => c.Resolve<ChannelFactory<ITestingEngineService>>().CreateChannel()).
                InstancePerHttpRequest().CacheInSession();

            builder.RegisterType<OnlineTestingEngineFacade>().AsImplementedInterfaces().InstancePerDependency();
        }
    }
}